gtk4.git
5 years agolistitemfactory: Reorganize vfuncs
Benjamin Otte [Sat, 2 Nov 2019 17:56:36 +0000 (18:56 +0100)]
listitemfactory: Reorganize vfuncs

Instead of bind/rebind/update/unbind, we now just have update, and the
factories get to interpret that in the way they want.

5 years agolistitem: Make this a GObject
Benjamin Otte [Fri, 1 Nov 2019 06:31:38 +0000 (07:31 +0100)]
listitem: Make this a GObject

This splits GtkListItem into 2 parts:

1. GtkListItem
   This is purely a GObject with public API for developers who want to
   populate lists. There is no chance to cause conflict with GtkWidget
   properties that the list implementation assumed control over and
   defines a clear boundary.
2. GtkListItemWidget
   The widget part of the listitem. This is not only fully in control of
   the list machinery, the machinery can also use different widget
   implementations for different list widgets like I inted to for
   GtkColumnView.

5 years agobuilder: Make gtk_builder_extend_with_template() work with objects
Benjamin Otte [Fri, 1 Nov 2019 06:30:32 +0000 (07:30 +0100)]
builder: Make gtk_builder_extend_with_template() work with objects

This will be relevant later when we introduce GtkListItem which is not a
GtkWidget.

5 years agogtk-demo: Add a Coverflow application launcher
Benjamin Otte [Tue, 29 Oct 2019 05:35:46 +0000 (06:35 +0100)]
gtk-demo: Add a Coverflow application launcher

This is roughly the simplest demo I could come up with.

But I documented it, so there's your tutorial.

Related: #2214

5 years agoAdd GtkSignalListItemFactory
Benjamin Otte [Tue, 29 Oct 2019 04:58:02 +0000 (05:58 +0100)]
Add GtkSignalListItemFactory

So the poor Rust users can actually use this.

I would totally not use this ever!

5 years agocolumnview: Allow adding/removing columns
Benjamin Otte [Mon, 28 Oct 2019 19:50:49 +0000 (20:50 +0100)]
columnview: Allow adding/removing columns

... and make that work in UI files via <child>, too.

5 years agogtk-demo: Add a minesweeper demo
Benjamin Otte [Mon, 28 Oct 2019 08:47:52 +0000 (09:47 +0100)]
gtk-demo: Add a minesweeper demo

The demo shows creating ones own listmodel and using it to fill a grid.

I am totally getting the hang of React btw:
500 lines of logic with no UI code and 100 lines of GtkBuilder XML and
I get a sweet UI.

5 years agoAdd GtkColumnView skeleton
Benjamin Otte [Mon, 28 Oct 2019 00:18:14 +0000 (01:18 +0100)]
Add GtkColumnView skeleton

It's just a copy/paste of the listview code with all the internals
gutted. The code doesn't do anything.

5 years agowip: Add GtkCoverFlow
Benjamin Otte [Sun, 27 Oct 2019 07:03:03 +0000 (08:03 +0100)]
wip: Add GtkCoverFlow

The widget mostly works out of the box, but some tweaking may be
necessary (in particular in the theme) and the gtk-demo changes might
require removing before this is production-ready.

5 years agolistbase: Take over anchor handling
Benjamin Otte [Sat, 26 Oct 2019 06:49:27 +0000 (08:49 +0200)]
listbase: Take over anchor handling

With that, pretty much all code but allocating the widgets is gone from
the gridview and listview.

5 years agolistbase: Add vfuncs to convert positions to/from coordinates
Benjamin Otte [Fri, 25 Oct 2019 05:39:57 +0000 (07:39 +0200)]
listbase: Add vfuncs to convert positions to/from coordinates

... and use that to implement PageUp/PageDown.

With that, all keyboard handling has been moved to GtkListBase.

5 years agolistbase: Move focus moving keybindings here
Benjamin Otte [Thu, 24 Oct 2019 04:49:38 +0000 (06:49 +0200)]
listbase: Move focus moving keybindings here

The focus tracker is not yet moved because that depends on scroll_to()
support and we don't have that yet.
Whoops.
So we use a hack.

5 years agoRemove gtk_selection_model_user_select_item() again
Benjamin Otte [Thu, 24 Oct 2019 00:14:34 +0000 (02:14 +0200)]
Remove gtk_selection_model_user_select_item() again

This reverts commit 6a164ab306dad9096bde736c907494c71086d3c4.

The function was awkward and we now have only one caller again, so we
can fold it back into it.

5 years agolistbase: Move orientable implementation here
Benjamin Otte [Thu, 24 Oct 2019 00:07:37 +0000 (02:07 +0200)]
listbase: Move orientable implementation here

5 years agolistbase: Move selection handling here
Benjamin Otte [Wed, 23 Oct 2019 13:02:02 +0000 (15:02 +0200)]
listbase: Move selection handling here

5 years agolistbase: Move item manager here
Benjamin Otte [Wed, 23 Oct 2019 00:34:28 +0000 (02:34 +0200)]
listbase: Move item manager here

Nothing really changes, because both ListView and GridView still keep
self->item_manager around, but it's set up to point at the base's item
manager.

This way we can slowly move things to GtkListBase that need the item
manager (like trackers).

5 years agolistbase: Move GtkScrollable implementation
Benjamin Otte [Tue, 22 Oct 2019 21:46:34 +0000 (23:46 +0200)]
listbase: Move GtkScrollable implementation

Shared code between GtkGridView and GtkListView.

5 years agoAdd GtkListBase
Benjamin Otte [Tue, 22 Oct 2019 06:01:16 +0000 (08:01 +0200)]
Add GtkListBase

This is a base item for GTK's list widgets so they can share some (read:
hopefully a lot of) code.

5 years agogridview: Simplify allocation code
Benjamin Otte [Tue, 22 Oct 2019 02:59:34 +0000 (04:59 +0200)]
gridview: Simplify allocation code

It doesn't fix the bug I'm after, but it looks a lot better.

5 years agolistview: Port various gridview improvements
Benjamin Otte [Tue, 22 Oct 2019 01:21:39 +0000 (03:21 +0200)]
listview: Port various gridview improvements

- Handle anchor as align + top/bottom
  This fixes behavior for cells that are higher than the view
- Add gtk_list_view_adjustment_is_flipped()
  This should fix RTL handling of horizontal lists
- Fix scrolling
  This should make scrolling more reliable, particularly on short lists
  that are only a few pages long.

5 years agodemo: Add a file browser demo
Benjamin Otte [Fri, 18 Oct 2019 18:47:48 +0000 (20:47 +0200)]
demo: Add a file browser demo

5 years agogridview: Add move keybindings
Benjamin Otte [Mon, 21 Oct 2019 02:11:24 +0000 (04:11 +0200)]
gridview: Add move keybindings

5 years agogridview: Implement (un)select all
Benjamin Otte [Sun, 20 Oct 2019 20:05:48 +0000 (22:05 +0200)]
gridview: Implement (un)select all

Adds listitem.select-all and listitem.unselect-all actions and installs
the same keybindings as the treeview for those actions.

5 years agogridview: Add a focus tracker
Benjamin Otte [Sun, 20 Oct 2019 18:09:24 +0000 (20:09 +0200)]
gridview: Add a focus tracker

... and use that to properly update selections when moving around with
the arrow keys.

5 years agogridview: Implement list.scroll-to action
Benjamin Otte [Sun, 20 Oct 2019 16:52:28 +0000 (18:52 +0200)]
gridview: Implement list.scroll-to action

5 years agogridview: Add activation
Benjamin Otte [Sun, 20 Oct 2019 06:13:36 +0000 (08:13 +0200)]
gridview: Add activation

5 years agogridview: Implement minimum row height
Benjamin Otte [Sat, 19 Oct 2019 19:45:24 +0000 (21:45 +0200)]
gridview: Implement minimum row height

We only allocate a certain amount of widgets - and we don't want to run
out of them. So we make all widgets high enough for this to never
happen.

5 years agogridview: Implement the list.select-item action
Benjamin Otte [Sat, 19 Oct 2019 19:32:56 +0000 (21:32 +0200)]
gridview: Implement the list.select-item action

5 years agoselectionmodel: Add gtk_selection_model_user_select_item()
Benjamin Otte [Sat, 19 Oct 2019 19:29:52 +0000 (21:29 +0200)]
selectionmodel: Add gtk_selection_model_user_select_item()

I'm not sure this should be public API because it's incredibly awkward.
But it should definitely be shared between list widget implementations.

5 years agogridview: Implement anchors and scrolling
Benjamin Otte [Sat, 19 Oct 2019 16:20:04 +0000 (18:20 +0200)]
gridview: Implement anchors and scrolling

5 years agolistitemmanager: Handle NULL factory
Benjamin Otte [Sat, 19 Oct 2019 01:19:56 +0000 (03:19 +0200)]
listitemmanager: Handle NULL factory

Just don't call it and create empty listitems.

5 years agodemo: Use a listview as sidebar
Timm Bäder [Tue, 15 Oct 2019 13:39:59 +0000 (15:39 +0200)]
demo: Use a listview as sidebar

5 years agogtk-demo: Introduce awards
Benjamin Otte [Fri, 31 May 2019 02:52:13 +0000 (04:52 +0200)]
gtk-demo: Introduce awards

We need a way to get a useful listbox, so here we go!

5 years agobuilder: Autofill scope property of listitemfactory
Benjamin Otte [Tue, 3 Dec 2019 06:37:24 +0000 (07:37 +0100)]
builder: Autofill scope property of listitemfactory

I couldn't come up with a better way to automatically inherit the scope
in the builder list item factory that didn't involve a magic
incantation in the XML file. And I do not want developers to know magic
incantations to do a thing that should pretty much always be done.

5 years agobuilderlistitemfactory: Add scope argument
Benjamin Otte [Tue, 3 Dec 2019 06:03:10 +0000 (07:03 +0100)]
builderlistitemfactory: Add scope argument

This way, the scope used when creating builder instances can be
influenced. This way, callbacks can be passed into the factory.

5 years agolistitemfactory: Make the builder factory properly buildable
Benjamin Otte [Fri, 18 Oct 2019 02:07:04 +0000 (04:07 +0200)]
listitemfactory: Make the builder factory properly buildable

Turn the construct arguments into construct properties so that they can
be set from ui files.

5 years agolistview: Add move keybindings
Benjamin Otte [Wed, 16 Oct 2019 19:31:50 +0000 (21:31 +0200)]
listview: Add move keybindings

My god, these are a lot.

And my god, these are complicated to get right.

5 years agolistview: Add gtk_list_view_get_position_at_y()
Benjamin Otte [Wed, 16 Oct 2019 19:31:00 +0000 (21:31 +0200)]
listview: Add gtk_list_view_get_position_at_y()

5 years agolistitem: Add "listitem.select" action and keybindings for it
Benjamin Otte [Wed, 16 Oct 2019 14:28:47 +0000 (16:28 +0200)]
listitem: Add "listitem.select" action and keybindings for it

In fact, grab space with all modifiers to toggle selection of the
current item.

5 years agolistview: Add a focus tracker
Benjamin Otte [Wed, 16 Oct 2019 12:57:39 +0000 (14:57 +0200)]
listview: Add a focus tracker

This ensures that the row with the input focus always stays available,
even when scrolled out of view.

5 years agolistview: Implement (un)select all
Benjamin Otte [Tue, 15 Oct 2019 23:59:01 +0000 (01:59 +0200)]
listview: Implement (un)select all

Adds listitem.select-all and listitem.unselect-all actions and installs
the same keybindings as the treeview for those actions.

5 years agolistview: Track focus movements and update selection
Benjamin Otte [Tue, 15 Oct 2019 21:45:33 +0000 (23:45 +0200)]
listview: Track focus movements and update selection

When focus moves via tab/arrow, we need to select the new item.

5 years agolistview: Implement activation
Benjamin Otte [Tue, 15 Oct 2019 21:06:36 +0000 (23:06 +0200)]
listview: Implement activation

- a GtkListview::activate signal
- a GtkListItem::activatable property
- activate list items on double clicks and <Enter> presses

5 years agotreeexpander: Implement input support
Benjamin Otte [Tue, 15 Oct 2019 04:07:26 +0000 (06:07 +0200)]
treeexpander: Implement input support

This implements all the keybindings from GtkTreeView that can be
supported.

It does not implement expand-all, because supporting that means
causing the TreeListModel to emit lots of create_model vfuncs which in
turn would cause many items-changed signal which in turn would cause
many signal handlers to run which in turn would make "expand-all" very
reentrant, and I'm uneasy about supporting that.

For the mouse, just add a click gesture to the expander icon that toggles
expanded state.

5 years agolistitem: Change focus handling
Benjamin Otte [Tue, 15 Oct 2019 02:18:10 +0000 (04:18 +0200)]
listitem: Change focus handling

Focus in the listitem now works like this:
1. If any child can take focus, do not ever attempt
   to take focus.
2. Otherwise, if this item is selectable or activatable,
   allow focusing this widget.

This makes sure every item in a list is focusable for
activation and selection handling, but no useless widgets
get focused and moving focus is as fast as possible.

5 years agoinspector: Make the recorder node list use a ListView
Benjamin Otte [Mon, 14 Oct 2019 04:50:40 +0000 (06:50 +0200)]
inspector: Make the recorder node list use a ListView

It's quite a bit faster now, but the code is also a bit more awkward.

Pain points:

- GtkTreeListModel cannot be created in UI files because it needs
  a CreateModelFunc.
  Using a signal for this doesn't work because autoexpand wants to
  expand the model before the signal handler is connected.

- The list item factory usage is still awkward. It's bearable here
  because the list items are very simple, but still.

5 years agoinspector: Use a GtkTreeExpander in the object tree
Benjamin Otte [Mon, 14 Oct 2019 04:22:41 +0000 (06:22 +0200)]
inspector: Use a GtkTreeExpander in the object tree

5 years agoinspector: Use a treeexpander in the recorder
Benjamin Otte [Mon, 14 Oct 2019 04:18:25 +0000 (06:18 +0200)]
inspector: Use a treeexpander in the recorder

5 years agodemo: Add a GSettings tree demo
Benjamin Otte [Sun, 13 Oct 2019 05:40:58 +0000 (07:40 +0200)]
demo: Add a GSettings tree demo

It is meant to look somewhat like dconf-editor when it is done.

So far, it's just a list.

5 years agoAdd GtkTreeExpander
Benjamin Otte [Mon, 14 Oct 2019 02:31:20 +0000 (04:31 +0200)]
Add GtkTreeExpander

This is a container widget that takes over all the duties of tree
expanding and collapsing.
It has to be a container so it can capture keybindings while focus is
inside the listitem.

So far, this widget does not allow interacting with it, but it shows the
expander arrow in its correct state.

Also, testlistview uses this widget now instead of implementing
expanding itself.

5 years agogridview: Actually do something
Benjamin Otte [Sat, 12 Oct 2019 20:53:13 +0000 (22:53 +0200)]
gridview: Actually do something

Implement measuring and allocating items - which makes the items appear
when drawing and allows interacting with the items.

However, the gridview still does not allow any user interaction
(including scrolling).

5 years agolistview: Pass the CSS name of listitems to the manager
Benjamin Otte [Sat, 12 Oct 2019 11:16:54 +0000 (13:16 +0200)]
listview: Pass the CSS name of listitems to the manager

... instead of hardcoding "row".

5 years agogridview: Implement GtkOrientable
Benjamin Otte [Thu, 10 Oct 2019 03:24:29 +0000 (05:24 +0200)]
gridview: Implement GtkOrientable

Again, this is just the skeleton, because the Gridview does nothing yet.

5 years agogridview: Add factory handling
Benjamin Otte [Thu, 10 Oct 2019 01:38:51 +0000 (03:38 +0200)]
gridview: Add factory handling

Just copy the listview APIs.

Code still doesn't do anything with it.

5 years agolistview: Expose GtkListItemFactory APIs
Benjamin Otte [Tue, 8 Oct 2019 22:07:07 +0000 (00:07 +0200)]
listview: Expose GtkListItemFactory APIs

Due to the many different ways to set factories, it makes sense to
expose them as custom objects.

This makes the actual APIs for the list widgets simpler, because they
can just have a regular "factory" property.

As a convenience function, gtk_list_view_new_with_factory() was added
to make this whole approach easy to use from C.

5 years agogtk-demo: Add a rough start at a Weather demo
Benjamin Otte [Mon, 7 Oct 2019 02:46:11 +0000 (04:46 +0200)]
gtk-demo: Add a rough start at a Weather demo

This demos a horizontal listview.

5 years agolistview: Implement GtkOrientable
Benjamin Otte [Sun, 6 Oct 2019 03:46:50 +0000 (05:46 +0200)]
listview: Implement GtkOrientable

5 years agotests: Add a rough form of multiselection
Benjamin Otte [Sun, 6 Oct 2019 02:17:14 +0000 (04:17 +0200)]
tests: Add a rough form of multiselection

Just store a "filechooser::selected" attribute in the GFileInfo if
the file is meant to be selected.

5 years agolistview: Implement extending selections
Benjamin Otte [Sun, 6 Oct 2019 02:10:09 +0000 (04:10 +0200)]
listview: Implement extending selections

Shift-clicking to extend selections now also works, imitating the
behavior of normal clicking and Windows Explorer (but not treeview):

1. We track the last selected item (normally, not via extend-clicking).

2. When shift-selecting, we modify the range from the last selected item
   to this item the same way we modify the regular item when not using
   shift:

2a. If Ctrl is not pressed, we select the range and unselect everything
    else.

2b. If Ctrl is pressed, we make the range have the same selection state
    as the last selected item:
    - If the last selected item is selected, select the range.
    - If the last selected item is not selected, unselect the range.

5 years agolistview: Add list.scroll_to_item action
Benjamin Otte [Fri, 4 Oct 2019 04:50:47 +0000 (06:50 +0200)]
listview: Add list.scroll_to_item action

The action scrolls the given item into view.

Listitems activate this action when they gain focus.

5 years agotestlistview: Load icons async
Benjamin Otte [Thu, 3 Oct 2019 04:50:51 +0000 (06:50 +0200)]
testlistview: Load icons async

Speeds up loading by 4x, because out of view icons aren't loaded
anymore.

5 years agotestlistview: Port to directory list
Benjamin Otte [Mon, 25 Nov 2019 07:26:55 +0000 (08:26 +0100)]
testlistview: Port to directory list

5 years agolistitemfactory: Add a factory for ui files
Benjamin Otte [Mon, 10 Jun 2019 02:58:45 +0000 (04:58 +0200)]
listitemfactory: Add a factory for ui files

Reuse <template> magic to initialize GtkListItems. This feels
amazingly hacky, but it also amazingly worked on the first try.

5 years agolistitemfactory: Split implementation out
Benjamin Otte [Mon, 10 Jun 2019 01:43:52 +0000 (03:43 +0200)]
listitemfactory: Split implementation out

.. into gtkfunctionslistitemfactory.c

Now we can add a different implmenetation.

5 years agolistitemfactory: vfuncify
Benjamin Otte [Sun, 9 Jun 2019 22:17:44 +0000 (00:17 +0200)]
listitemfactory: vfuncify

No functional changes other than a new indirection.

5 years agolistitemfactory: Sanitize APIs
Benjamin Otte [Sun, 9 Jun 2019 20:50:46 +0000 (22:50 +0200)]
listitemfactory: Sanitize APIs

Make sure the APIs follow a predictable path:

setup
  bind
    rebind/update (0-N times)
  unbind
teardown

This is the first step towards providing multiple different factories.

5 years agolistview: Add gtk_list_view_set_show_separators()
Benjamin Otte [Tue, 4 Jun 2019 01:01:15 +0000 (03:01 +0200)]
listview: Add gtk_list_view_set_show_separators()

Do the same thing that GtkListBox does in commit
0249bd4f8a03ec473f3ca9d4324a3a8b75bd3f44

5 years agolistitemmanager: Add trackers
Benjamin Otte [Wed, 27 Feb 2019 07:45:28 +0000 (08:45 +0100)]
listitemmanager: Add trackers

... and replace the anchor tracking with a tracker.

Trackers track an item through the list across changes and ensure that
this item (and potentially siblings before/after it) are always backed
by a GtkListItem and that if the item gets removed a replacement gets
chosen.

This is now used for tracking the anchor but can also be used to add
trackers for the cursor later.

5 years agolistitemmanager: Simplify
Benjamin Otte [Fri, 22 Feb 2019 02:05:54 +0000 (03:05 +0100)]
listitemmanager: Simplify

Remove a bunch of API from the headers that isn't used anymore and then
refactor code to not call it anymore.

In particular, get rid of GtkListItemManagerChange and replace it with a
GHashTable.

5 years agogridview: Implement GtkScrollable
Benjamin Otte [Wed, 6 Feb 2019 20:18:33 +0000 (21:18 +0100)]
gridview: Implement GtkScrollable

We can now scroll all the nothing we display.

We also clip it properly.

5 years agolistitemmanager: Move list of listitems here
Benjamin Otte [Wed, 6 Feb 2019 19:48:08 +0000 (20:48 +0100)]
listitemmanager: Move list of listitems here

All the listview infrastructure moved with it, so the next step is
moving that back...

5 years agogridview: Add API for setting number of columns
Benjamin Otte [Mon, 28 Jan 2019 01:24:34 +0000 (02:24 +0100)]
gridview: Add API for setting number of columns

The API isn't used yet.

5 years agogtk: Add a GtkGridView skeleton
Benjamin Otte [Sun, 27 Jan 2019 19:15:23 +0000 (20:15 +0100)]
gtk: Add a GtkGridView skeleton

5 years agolistitem: Add a press gesture to select the item
Benjamin Otte [Fri, 5 Oct 2018 21:24:18 +0000 (23:24 +0200)]
listitem: Add a press gesture to select the item

This is implemented by using actions, which are a neat trick to get to
allow the ListItem to call functions on the ListView without actually
needing to be aware of it.

5 years agolistview: Add initial support for displaying selections
Benjamin Otte [Wed, 3 Oct 2018 16:53:06 +0000 (18:53 +0200)]
listview: Add initial support for displaying selections

5 years agolistview: Reset listitems' CSS animations when rebinding
Benjamin Otte [Sat, 29 Sep 2018 20:38:09 +0000 (22:38 +0200)]
listview: Reset listitems' CSS animations when rebinding

This way, newly displayed rows don't play an unselect animation (text
fading in) when they are unselected, but the row was previously used for
a selected item.

5 years agolistview: Add selection properties to ListItem
Benjamin Otte [Sat, 29 Sep 2018 20:34:43 +0000 (22:34 +0200)]
listview: Add selection properties to ListItem

This just brings the infrastructure into place, we're not using the
properties yet.

5 years agolistview: Try to keep the list items in order when scrolling
Benjamin Otte [Fri, 28 Sep 2018 01:33:16 +0000 (03:33 +0200)]
listview: Try to keep the list items in order when scrolling

Instead of just destroying all items and then recreating them (or even
hide()ing and then show()ing them again (or even even repositioning
them in the widget tree)), just try to reust them in the order they are.

This works surprisingly well when scrolling and most/all widgets
just moved.

5 years agolistlistmodel: Add gtk_list_list_model_item_moved()
Benjamin Otte [Fri, 28 Sep 2018 00:45:54 +0000 (02:45 +0200)]
listlistmodel: Add gtk_list_list_model_item_moved()

Use it to fix a case that just said g_warning ("oops").

Apparently I had forgotten the case where a container moved a child
in the widget tree.

5 years agolistitemmanager: Switch from "insert_before" to "insert_after" argumnet
Benjamin Otte [Fri, 28 Sep 2018 00:05:46 +0000 (02:05 +0200)]
listitemmanager: Switch from "insert_before" to "insert_after" argumnet

We reorder widgets start to end, so when reusing a list item, we
correctly know the previous sibling for that list item, but not the
next sibling yet. We just know the widget it should ultimately be in
front of.
So we can do a more correct guess of the list item's place in the widget
tree if we think about where to place an item like this.

Actually using this change will come in the next commit.

5 years agotestlistview: Create widgets only once
Benjamin Otte [Wed, 26 Sep 2018 00:18:13 +0000 (02:18 +0200)]
testlistview: Create widgets only once

Previously, we were recreating all widgets every time the list item was
rebound, which caused a lot of extra work every time we scrolled.

Now we keep the widgets around and only set their properties again when
the item changes.

5 years agotestlistview: Show the row number
Benjamin Otte [Tue, 25 Sep 2018 23:41:39 +0000 (01:41 +0200)]
testlistview: Show the row number

Always show the current row. This is mostly useful for debugging, not
for beauty.

5 years agolistview: Only allocate necesary rows
Benjamin Otte [Tue, 25 Sep 2018 23:37:38 +0000 (01:37 +0200)]
listview: Only allocate necesary rows

This is the big one.

The listview only allocates 200 rows around the visible row now.
Everything else is kept in ListRow instances with row->widget == NULL.

For rows without a widget, we assign the median height of the child
widgets as the row's height and then do all calculations as if there
were widgets that had requested that height (like setting adjustment
values or reacting to adjustment value changes).

When the view is scrolled, we bind the 200 rows to the new visible area,
so that the part of the listview that can be seen is always allocated.

5 years agolistview: Change anchor handling again
Benjamin Otte [Mon, 24 Sep 2018 22:16:27 +0000 (00:16 +0200)]
listview: Change anchor handling again

The anchor is now a tuple of { listitem, align }.

Using the actual list item allows keeping the anchor across changes
in position (ie when lists get resorted) while still being able to fall
back to positions (list items store their position) when an item gets
removed.

The align value is in the range [0..1] and defines where in the visible
area to do the alignment.
0.0 means to align the top of the row with the top of the visible area,
1.0 aligns the bottom of the widget with the visible area and 0.5 keeps
the center of the widget at the center of the visible area.
It works conceptually the same as percentages in CSS background-position
(where the background area and the background image's size are matched
the same way) or CSS transform-origin.

5 years agolistview: Change how binding is done
Benjamin Otte [Mon, 24 Sep 2018 02:42:15 +0000 (04:42 +0200)]
listview: Change how binding is done

We now don't let the functions create widgets for the item from the
listmodel, instead we hand out a GtkListItem for them to add a widget
to.

GtkListItems are created in advance and can only be filled in by the
binding code by gtk_container_add()ing a widget.
However, they are GObjects, so they can provide properties that the
binding code can make use of - either via notify signals or GBinding.

5 years agolistitem: Add gtk_list_item_get_position()
Benjamin Otte [Mon, 24 Sep 2018 02:01:37 +0000 (04:01 +0200)]
listitem: Add gtk_list_item_get_position()

Also refactor the whole list item management yet again.

Now, list item APIs doesn't have bind/unbind functions anymore, but only
property setters.

The item factory is the only one doing the binding.
As before, the item manager manages when items need to be bound.

5 years agotests: Make animating listview do random resorts
Benjamin Otte [Sat, 22 Sep 2018 20:14:25 +0000 (22:14 +0200)]
tests: Make animating listview do random resorts

5 years agolistview: Change change management
Benjamin Otte [Sat, 22 Sep 2018 20:11:27 +0000 (22:11 +0200)]
listview: Change change management

Add a GtkListItemManagerChange object that tracks all removed list
rows during an item-changed signal so they can be added back later.

5 years agolistview: Make the listitemmanager stricter
Benjamin Otte [Fri, 21 Sep 2018 03:32:00 +0000 (05:32 +0200)]
listview: Make the listitemmanager stricter

Require that items created with the manager get destroyed via the
manager.

To that purpose, renamed create_list_item() to acquire_list_item() and
add a matching release_list_item() function.

This way, the manager can in the future keep track of all items and
cache information about them.

5 years agolistview: Add GtkListItem
Benjamin Otte [Fri, 21 Sep 2018 03:05:34 +0000 (05:05 +0200)]
listview: Add GtkListItem

GtkListItem is a generic row widget that is supposed to replace
GtkListBoxRow and GtkFlowBoxChild.

5 years agolistview: Add GtkListItemManager
Benjamin Otte [Thu, 20 Sep 2018 03:18:34 +0000 (05:18 +0200)]
listview: Add GtkListItemManager

It's all stubs for now, but here's the basic ideas about what
this object is supposed to do:

(1) It's supposed to be handling all the child GtkWidgets that are
    used by the listview, so that the listview can concern
    itself with how many items it needs and where to put them.
(2) It's meant to do the caching of widgets that are not (currently)
    used.
(3) It's meant to track items that remain in the model across
    items-changed emissions and just change position.
(2) It's code that can be shared between listview and potential
    other widgets like a GridView.

It's also free to assume that the number of items it's supposed to
manage doesn't grow too much, so it's free to use O(N) algorithms.

5 years agolistview: Implement an anchor
Benjamin Otte [Wed, 19 Sep 2018 05:08:30 +0000 (07:08 +0200)]
listview: Implement an anchor

The anchor selection is very basic: just anchor the top row.

That's vastly better than any other widget already though.

5 years agotests: Add a test for a permanently changing listview
Benjamin Otte [Wed, 19 Sep 2018 02:29:33 +0000 (04:29 +0200)]
tests: Add a test for a permanently changing listview

This is mostly for dealing with proper anchoring and can be used to
check that things don't scroll or that selection and focus handling
properly works.

For comparison purposes, a ListBox is provided next to it.

5 years agolistview: Implement GtkScrollable
Benjamin Otte [Tue, 18 Sep 2018 17:58:19 +0000 (19:58 +0200)]
listview: Implement GtkScrollable

Scrolling in a very basic form is also supported

5 years agolistview: Make widget actually do something
Benjamin Otte [Tue, 18 Sep 2018 02:56:19 +0000 (04:56 +0200)]
listview: Make widget actually do something

The thing we're actually doing is create and maintain a widget for every
row. That's it.

Also add a testcase using this. The testcase quickly allocates too many
rows though and then becomes unresponsive though. You have been warned.

5 years agolistview: Introduce GtkListItemFactory
Benjamin Otte [Mon, 17 Sep 2018 05:29:50 +0000 (07:29 +0200)]
listview: Introduce GtkListItemFactory

Thisis the abstraction I intend to use for creating widgets and binding
them to the item out of the listview.

For now this is a very dumb wrapper around the functions that exist in
the API.

But it leaves the freedom to turn this into public API, make an
interface out of it and most of all write different implementations, in
particular one that uses GtkBuilder.

5 years agogtk: Add a GtkListView skeleton
Benjamin Otte [Sun, 16 Sep 2018 18:52:06 +0000 (20:52 +0200)]
gtk: Add a GtkListView skeleton

5 years agobuilder: Add <binding> tag
Benjamin Otte [Mon, 25 Nov 2019 07:15:31 +0000 (08:15 +0100)]
builder: Add <binding> tag

The tag contains an expression that it then gtk_expression_bind()s to
the object it is contained in.

5 years agobuilder: Allow text content in <lookup>
Benjamin Otte [Mon, 25 Nov 2019 07:06:45 +0000 (08:06 +0100)]
builder: Allow text content in <lookup>

  <lookup>foo</lookup>
is now short for
  <lookup>
    <constant>foo</constant>
  </lookup>
ie it looks up the object with the given name so it can then do a
property lookup with it.

This is the most common operation, so it's a nice shortcut.

5 years agobuilder: Allow <constant> without a type
Benjamin Otte [Mon, 25 Nov 2019 07:04:24 +0000 (08:04 +0100)]
builder: Allow <constant> without a type

A constant without a type is assumed to be an object. This is the most
common case and allows
  <constant>foo</constant>
without requiring updates to the type whenever the foo object changes.